$(document).ready(function() {load();}).unload(function() {GUnload();});

var points = "<?php echo addslashes($this->track->encoded_points) ?>";
var levels = "<?php echo addslashes($this->track->encoded_levels) ?>";
var mgr;
var markers = [];

function load()
{
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GScaleControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GLargeMapControl());
		map.enableScrollWheelZoom();
		map.enableContinuousZoom();
		map.enableDoubleClickZoom();
		
		// wikipedia
		var wikipedia = new GLayer("org.wikipedia.pl");
		map.addOverlay(wikipedia);
		
		// fotki
		mgr = new GMarkerManager(map, {trackMarkers: true});
		

		mgr.refresh();
		<?php $begin = reset($this->track->path); ?>
		map.setCenter(new GLatLng(<?php echo $begin['x'] ?>, <?php echo $begin['y'] ?>), 13);
		var polyline = new GPolyline.fromEncoded({
			'color': "#0000FF",
			'weight': 5,
			'points': points,
			'zoomFactor': 32,
			'levels': levels,
			'numLevels': 4
		});
		
		map.addOverlay(polyline);
	}
}